Professional Documents
Culture Documents
P - CNT - Ce CNT - RST: Counter 7-Bit Ce Reset Q TC CLK Counter 7-Bit Ce Reset Q
P - CNT - Ce CNT - RST: Counter 7-Bit Ce Reset Q TC CLK Counter 7-Bit Ce Reset Q
p_cnt_ce
cnt_rst
counter
7-bit
ab_cnt_ce ce Q
reset TC ab_cnt_tc
clk
SSRAM counter
7-bit
A
ce Q
a_data D_in D_out
reset
ab_rd en
clk
wr SSRAM
clk A
× D_in D_out p_data
en
SSRAM wr
A clk
b_data D_in D_out
en
wr
clk
p_wr
clk
The two SSRAMs on the left store the elements of the vectors a and b, and
the SSRAM on the right stores the elements of the vector p. This datapath
is simplified from a complete version, since it does not include provision
for writing the vector values into the a and b memories or reading the val-
ues from the p memory. We will return to that shortly.
The addresses for the memories are generated by the two counters, each
of which starts from 0 and increments cycle-by-cycle up to 127 as corre-
sponding elements from a and b are read, multiplied, and the product
stored. Given that the computation takes a cycle, the address for the p
memory must lag one behind the address for the a and b memories. That
is why we use separate counters with separate count-enable control in-
puts. The timing for computation of a complete vector product, starting
Peter J. Ashenden, Digital Design: An Embedded Systems Approach Using Verilog — 21 September 2007.
© 2007 by Elsevier Inc. Reproduced with permission from the publisher.
with the go input being activated and finishing with the done output being
activated, is:
state idle idle cmp0 comp comp comp comp last result idle
clk
go
cnt_rst
ab_cnt_ce
a/b address 0 1 2 3 126 127 0
ab_rd
a/b SSRAM output 0 1 2 125 126 127 0
p_cnt_ce
p address 0 1 2 125 126 127 0
ab_cnt_tc
p_wr
done
We have also shown the control steps on this diagram. They will be im-
plemented by the control section. The counters are held reset when the cir-
cuit is idle. When the go input is activated, the counter reset signal is
deactiviated, but only the a and b address counter is enabled. The a and b
memories are enabled to read. In the next cycle, the elements at address 0
appear at the SSRAM outputs and are multiplied together. The p memory
address counter is enabled (one cycle behind the a and b memory address
counter, hence it lags by 1), and the p memory is enabled to write. On sub-
sequent cycles, the operations repeat, until the a and b address counter
reaches its terminal count. There is then one last cycle to compute and
write the final product to the p memory. After that, the done output is ac-
tivated for a cycle and the counters are reset.
addr_sel
p_addr
p_cnt_ce
cnt_rst
counter
7-bit
ab_cnt_ce ce Q
reset TC ab_cnt_tc
clk 1
a_addr 0 SSRAM counter
7-bit 0
A
ce Q 1
a_data D_in D_out
ab_rd reset
en
clk
a_wr_en wr SSRAM
clk A
× D_in D_out p_data
1
en
b_addr 0 SSRAM wr
A clk
b_data D_in D_out
en
b_wr_en wr
clk
p_rd_en
p_wr
clk
The control signal addr_sel is 0 in the idle state and 1 in all other states.
module dual_port_SSRAM_synth_a
( output reg [15:0] d_out1,
input [15:0] d_in1,
input [11:0] a1,
input en1, wr1,
output reg [15:0] d_out2,
input [11:0] a2,
input [11:0] en2,
input clk );
endmodule
module dual_port_SSRAM_synth_b
( output reg [15:0] d_out1,
input [15:0] d_in1,
input [11:0] a1,
input en1, wr1,
output reg [15:0] d_out2,
input [11:0] a2,
input [11:0] en2,
input clk );
Peter J. Ashenden, Digital Design: An Embedded Systems Approach Using Verilog — 21 September 2007.
© 2007 by Elsevier Inc. Reproduced with permission from the publisher.
endmodule
The code representing the read port explicitly tests whether the read/write
port is performing a write to the same address, and if so, uses the written
data. The reason for including this explicit test is that the update to the
memory array does not take place until after the alway block has complet-
ed executing. Had we not included the test and action in this way, the read
port would read the old value from the array.
e1 = d1 d2 d4 d5 d7 = 1 0 1 0 1 = 1
e2 = d1 d3 d4 d6 d7 = 1 0 1 1 1 = 0
e4 = d2 d3 d4 d8 = 0 0 1 0= 1
e8 = d5 d6 d7 d8 = 0 1 1 0= 0
exercise 5.26 a) The check bits read from memory are 0110.
The check bits computed from the data bits of the ECC word are
e1 = e3 e5 e7 e9 e11 = 0 1 0 1 0 = 0
e2 = e3 e6 e7 e10 e11 = 0 1 0 0 0 = 1
e4 = e5 e6 e7 e12 = 1 1 0 1= 1
The syndrome is 0110 0110 = 0000. Thus, there is no error in the read
ECC. The data is 10010010.
The check bits computed from the data bits of the ECC word are
e1 = e3 e5 e7 e9 e11 = 0 1 0 1 0 = 0
e2 = e3 e6 e7 e10 e11 = 0 1 0 0 0 = 1
e4 = e5 e6 e7 e12 = 1 1 0 0= 0
The check bits computed from the data bits of the ECC word are
e1 = e3 e5 e7 e9 e11 = 1 1 1 0 1 = 0
Peter J. Ashenden, Digital Design: An Embedded Systems Approach Using Verilog — 21 September 2007.
© 2007 by Elsevier Inc. Reproduced with permission from the publisher.
e2 = e3 e6 e7 e10 e11 = 1 0 1 1 1 = 0
e4 = e5 e6 e7 e12 = 1 0 1 1= 1
e21 e20 e19 e18 e17 e16 e15 e14 e13 e12 e11 e10 e9 e8 e7 e6 e5 e4 e3 e2 e1