From a17dafb4961bc8b849a09c69d1129f75cf1e267e Mon Sep 17 00:00:00 2001 From: Nicolas Schodet Date: Wed, 1 Aug 2007 09:55:47 +0200 Subject: Fixed switch operand sizes in quad_decoder_div4. Added an output latch, now output will not change when oe is one. --- digital/asserv/src/hdlcounter/counter_top.v | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'digital/asserv/src/hdlcounter/counter_top.v') diff --git a/digital/asserv/src/hdlcounter/counter_top.v b/digital/asserv/src/hdlcounter/counter_top.v index fa1b737c..0c313704 100644 --- a/digital/asserv/src/hdlcounter/counter_top.v +++ b/digital/asserv/src/hdlcounter/counter_top.v @@ -48,11 +48,21 @@ module counter_top(clk, rst, q0, q1, q2, q3, oe, sel, count); input_latch f3[1:0] (clk, rst, q3, qf3); quad_decoder_full qd3 (clk, rst, qf3, count3); - assign count = - !oe ? 8'bz : - sel == 0 ? count0 : - sel == 1 ? count1 : - sel == 2 ? count2 : - count3; + reg [size-1:0] lcount; + + always @(posedge clk or negedge rst) begin + if (!rst) + lcount <= 0; + else begin + if (!oe) begin + lcount <= sel == 0 ? count0 : + sel == 1 ? count1 : + sel == 2 ? count2 : + count3; + end + end + end + + assign count = !oe ? 8'bz : lcount; endmodule -- cgit v1.2.3