Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

problem in register interfacing

Status
Not open for further replies.

gmish27

Member level 1
Member level 1
Joined
May 12, 2011
Messages
34
Helped
3
Reputation
6
Reaction score
3
Trophy points
1,288
Activity points
1,553
here is my code that i have used to make a register for my basic computer:


Code Verilog - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
module register #(parameter n=2)
    (
    input inc,we,
    input clr,clk,
    input [n-1:0] idat,
    output [n-1:0] odat
    );
     
    reg [n-1:0] data;
    
    always@(posedge clk, posedge clr)
        if(clr)
            data <= 0;
        else if(inc)
            data <= data + 1;
        else if(we)
            data <= idat;
            
    assign odat = data;
 
 
endmodule



Now when i am using this register as a top module to check the functioning of it like if provide an 'inc=1'b1' signal in the test bench, the output i.e 'odat' becomes high in the same clock cycle.

But when i interface this register to the control signals as if:
inc = control_signal[1];

the output 'odat' gets high in the next clock cycle. please tell why???
 

For first case you need to see the relation of inc=1'b1 wrt clk in your test bench
Make inc=1'b1 wrt @clk then you should not see a problem
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top