Documente Academic
Documente Profesional
Documente Cultură
Overview
Combinational Logic
Registers
Mealy
Moore
Control vs. Datapath
Implicit FSM Design
:
:
:
:
a
a
a
a
=
=
=
=
8d1;
8d2;
8d3;
8d4;
a
a
a
a
=
=
=
=
8d1;
8d2;
8d3;
8d4;
synopsys parallel_case
a = 8d1;
a = 8d2;
a = 8d3;
a = 8d4;
=
=
=
=
=
=
=
=
=
=
=
ZERO;
ONE;
TWO;
THREE;
FOUR;
FIVE;
SIX;
SEVEN;
EIGHT;
NINE;
BLANK;
Parameters are
very useful.
Well talk about
more uses of
parameters
later.
Overview
Combinational Logic
Registers
Mealy
Moore
Control vs. Datapath
Implicit FSM Design
Ring Counter
module ring_counter (count, enable, clock, reset);
output reg [7:0] count;
input
enable, clock , reset;
always @ (posedge reset, posedge clock)
if (reset == 1'b1)
count <= 8'b0000_0001;
else if (enable == 1b1) begin
case (count)
8b0000_0001: count <= 8b0000_0010;
8b0000_0010: count <= 8b0000_0100;
Ring Counter
module ring_counter (count, enable, clock, reset);
output reg [7:0] count;
input
enable, reset, clock;
always @ (posedge reset or posedge clock)
if (reset == 1'b1)
count <= 8'b0000_0001;
else if (enable == 1'b1) count <= {count[6:0], count[7]};
//else count <= count; Is inferred by lack of an else
endmodule
Register File
module Register_File (Data_Out_1, Data_Out_2, Data_in, Read_Addr_1,
Read_Addr_2, Write_Addr, Write_Enable, Clock);
output [15:0] Data_Out_1, Data_Out_2;
input
[15:0] Data_in;
input
[2:0] Read_Addr_1, Read_Addr_2, Write_Addr;
input
Write, Enable, Clock;
reg
[15:0] Reg_File [0:7]; // 16-bit by 8-word memory declaration
always @ (posedge Clock) begin
if (Write_Enable) Reg_File [Write_Addr] <= Data_in;
Data_Out_1 <= Reg_File[Read_Addr_1];
Data_Out_2 <= Reg_File[Read_Addr_2];
end
endmodule
What kind of read and write capability does this module have?
Are the reads and writesCourtesy:
synchronous
orEricasynchronous?
Mike Morrow and
Hoffman
Overview
Combinational Logic
Registers
Mealy
Moore
Control vs. Datapath
Implicit FSM Design
Explicit
Implicit
Moore
Mealy
Next State
Logic
State Register
Current State
Next State
FF
Output
Logic
Outputs
State Diagram
Outputs Y and Z are 0,
unless specified otherwise.
a=0
S0
b=0
a = 1/
Z=1
S1
Y=1
b = 1/ Z = 1
reset = 1
S2
S0
a=1
b = x/
Y = 0,
Z=1
reset = 1
ab = xx/
YZ = 00
a=x
b = 0/
Y = 1,
Z=0
S1
// output logic
always@(state, a, b) begin
Z = 1b0, Y = 1b0; //avoids latch
case (state)
S0: if (a) Z = 1;
S1: begin
Y = 1;
if (b) Z = 1;
end
S2: ;
// Z = 0, Y = 0
default: begin
Y = 1bx; Z = 1bx; end
endcase
endmodule
Mealy FSM
Inputs
Outputs
FF
if (b)
begin
next_state = S2;
Z = 1;
end
else
next_state = S1;
end
S2: next_state = S0;
default: begin
next_state = 2bx; Y = 1bx;
Z = 1bx; end
endcase
endmodule
Outputs
FF
FF
Inputs
FF
Combinational
Outputs
FF
Overview
Combinational Logic
Registers
Mealy
Moore
Control vs. Datapath
Implicit FSM Design
b=0
a=1
S1
Y=1
b=1
reset = 1
S2
Z=1
Moore FSM
Inputs
Next State
Logic
State Register
Current State
Next State
FF
Output
Logic
Outputs
//output logic
always@(state) begin
Z = 0, Y = 0; // avoids latches
case (state)
S0: ;
S1: Y = 1;
S2: Z = 1;
default: begin
Y = 1bx; Z = 1bx; end
endcase
end
endmodule
Overview
Combinational Logic
Registers
Mealy
Moore
Control vs. Datapath
Implicit FSM Design
Specification:
more = 3 / add = 1
more = 2 / add = 1
SDONE
S0
more = 0
/ add = 0
add = 1
S1
more = 1
/ add = 1
Courtesy: Mike Morrow and Eric Hoffman
add = 1
S2
initial state <= S0; // May not synthesize, better to rely on rst
always@(posedge clk or posedge rst)
if (rst) state <= S0;
else state <= next;
//output logic
always@(state,more) begin
case (state)
SDONE: add = 0;
S0:
add = |more;
default: add = 1;
endcase
end
endmodule
Overview
Combinational Logic
Registers
Mealy
Moore
Control vs. Datapath
Implicit FSM Design
IMPLICIT
EXPLICIT
always begin
@(posedge clk) count <= 0;
@(posedge clk) count <= count + 1;
@(posedge clk) count <= count + 1;
end
Implicit
Review Questions
Review Questions