Mombu the Programming Forum

Go Back   Mombu the Programming Forum > Programming > Programming languages > Verilog - Race Condition - Please Help !!
User Name
Password
REGISTER NOW! Mark Forums Read




Reply Bookmark and Share
1 24th October 04:29
dash82
Miembro
Mombu User
 
Join Date: Oct 2007
Location: ND,US
Posts: 1
dash82 is on a distinguished road
Default Verilog - Race Condition - Please Help !!



I completely modified my code. I guess i am facing one final glitch. I think my logic is correct for 1/2 rate Convolutional Encoder with generator polynomials (1,1,1) & (1,0,1). However, I see a race condition.

I am using "reset" variable to control the set of statements that gets executed. However, I am seeing that all the assignment statements are getting executed everytime, irrespective of the "reset" variable condition.

I want to make my code synthesizable too. Any help would be greatly appreciated. Please excuse me if this question annoys you. Still learning.

Code:


module conencoder (out1,out2,in1,clock,reset);
output out1,out2;
input in1,clock,reset;
reg u0,u1,u2,temp_u0,temp_u1,temp_u2;
reg out1,out2;

initial
begin
//if (reset)
//begin
assign out1 = 1'b0;
assign out2 = 1'b0;
assign u0 = 1'b0;
assign u1 = 1'b0;
assign u2 = 1'b0;
assign temp_u0 = 1'b0;
assign temp_u1 = 1'b0;
assign temp_u2 = 1'b0;
//end
end

always @(clock)
begin
if (reset)
begin
//shifting the input bit through 3 registers.
assign u2 = temp_u1;
assign u1 = temp_u0;
assign u0 = in1 ;
end
else if (!reset)
begin
//performing xor operation to produce the encoded bits. ERROR:All assignment statements are getting
//executed irrespective of "reset" variable block checking.
assign out1 = (u2 ^ u1 ^ u0);
assign out2 = (u2 ^ u0);
assign temp_u1 = u1 ;
assign temp_u0 = u0 ;
end
end

endmodule

----------------------------------------------------------------------------------------
testbench:
--------------

module testbench ;
reg clock,reset,in1 = 1'b0;


conencoder r1(out1,out2,in1,clock,reset);

initial
begin
//clock = 1'b1;
//reset = 1'b1;
end

/*always
begin
// #30 clock = ~clock ;
end */

always
begin
#3 reset = 1'b1 ;
#2 in1 = 1'b1;
#3 clock = 1'b1 ;
#3 reset = 1'b0;
#3 clock = 1'b0;
//ERROR STARTS. After this all assignment statements seems to be getting executed in main code.
#3 reset = 1'b1 ;
#2 in1 = 1'b1;
#3 clock = 1'b1 ;
#3 reset = 1'b0;
#3 clock = 1'b0;
#3 reset = 1'b1 ;
#2 in1 = 1'b1;
#3 clock = 1'b1 ;
#3 reset = 1'b0;
#3 clock = 1'b0;
#3 reset = 1'b1 ;
#2 in1 = 1'b1;
#3 clock = 1'b1 ;
#3 reset = 1'b0;
#3 clock = 1'b0;
#3 reset = 1'b1 ;
#2 in1 = 1'b1;
#3 clock = 1'b1 ;
#3 reset = 1'b0;
#3 clock = 1'b0;


end

endmodule

-------------------------------------------------------------------------------

The above code is compiled with ModelSim and works fine. I know I am making some stupid mistake due to which
all 'assignment' statements are getting executed in the main code. Please help and I apologize for a long description.
dash82 is offline   Reply With Quote


 


Reply


Thread Tools
Display Modes


Some other forums that might be of your interest : Development, Ada, Apple script, Assembler, Awk, Beos, Basic, C, C++, C#, C# .net, .net, .net frameworks, Asp .net, Clarion, Clipper, Clos, Clu, Cobol, Coldfusion, Delphi, Dylan, Eiffel, Forth, Fortran, Haskell, Hermes, Icon, Idl, Java, Java script, Jscript .net, Jcl, Linoleum, Lisp, Lotus, Limbo, Logo, Ml, Mumps, Oberon, Postscript, Pop, Pl1, Prolog, Python, Ruby, Pascal, Perl, Php, Rebol, Rexx, Sed, Sather, Scheme, Smalltalk, Tcl, Vhdl, Vrml, Visual basic, Visual basic .net, Yorick, Mysql, Omnis, Postgresql, Xbase, Access, Oracle, Adabas, Berkeley, Btrieve, Filemaker, Gupta, Db2, Informix, Ingres, Mssql server, Object, Olap, Paradox, Rdb, Revelation, Sybase, Theory, Dbase, Html, Java script, Css, Flash, Photoshop, Corel script, Xml, Tech, Beos, Gem, Hp48, Hpux, Linux, Mac, Ms-dos, Os2, Palm, Solaris, Ti99, Windows, Xenix, Aos, Chorus, Geos, Inferno, Lantastic, Lynx, Mach, Minix, Netware, Os9, Parix, Plan9, Psos, Qnx, Xinu, Sco, Unix, Aix, Aux, 386bsd, Bsdi, Freebsd, Netbsd, Openbsd, Ultrix, Amd, Intel, Aptiva, Buz, Deals, Homebuilt, Overclocking, Programming, Extra forums


Copyright © 2006 SmartyDevil.com - Dies Mies Jeschet Boenedoesef Douvema Enitemaus -
666