$monitor and icarus (iverilog)

  • Permalink
  • submit to reddit
  • Email
  • Follow


Newbie Alert. Learning verilog with gEDA tools - icarus

I am trying to implement a traffic light controller. Nothing complicated 
here but I thought Id use system functions to simulate it ($monitor, 
$display).

Compiles correctly with 
iverilog -s top traffic_light.v

I run it with
vvp a.out and it produces the following:

TrafficLights=x
                   0	rst=1	clk=0	sw= 4	leds=X
TrafficLights=6
                   5	rst=1	clk=1	sw= 4	leds=X
TrafficLights=5
                  10	rst=0	clk=0	sw= 4	leds=X
TrafficLights=6
                  15	rst=1	clk=1	sw= 4	leds=X
                  20	rst=1	clk=0	sw= 4	leds=X
TrafficLights=5
                  25	rst=1	clk=1	sw= 4	leds=X
                  30	rst=1	clk=0	sw= 4	leds=X
TrafficLights=3
                  35	rst=1	clk=1	sw= 4	leds=X
                  40	rst=1	clk=0	sw= 4	leds=X
TrafficLights=6
                  45	rst=1	clk=1	sw= 4	leds=X
                  50	rst=1	clk=0	sw= 4	leds=X
TrafficLights=5
                  55	rst=1	clk=1	sw= 4	leds=X
                  60	rst=1	clk=0	sw= 4	leds=X
TrafficLights=3
                  65	rst=1	clk=1	sw= 4	leds=X
                  70	rst=1	clk=0	sw= 4	leds=X
TrafficLights=6
                  75	rst=1	clk=1	sw= 4	leds=X
                  80	rst=1	clk=0	sw= 4	leds=X
TrafficLights=5
                  85	rst=1	clk=1	sw= 4	leds=X
                  90	rst=1	clk=0	sw= 4	leds=X
TrafficLights=3
                  95	rst=1	clk=1	sw= 4	leds=X
                 100	rst=1	clk=0	sw= 4	leds=X



internal to the module the variable changes as expected, why isnt
this represented in the $monitor function' output in module top?

what am I not understanding?
Thanks



/*
 ************************************************************************
 *name:         traffic_light.v
 *author:       Samuel Igwe
 *date:         2/8/2011 A.D
 *description:  verilog code to allow the xilinx xc95108 cpld board I put
 *              together to function like a traffic light indicator
 ************************************************************************
 */
module  top;
reg             SymClk=0,SymRst=1;
wire    [3:0]   SymSwitch=4;
wire    [2:0]   SymLeds=0;

traffic_light symtraffic (SymRst,SymClk,SymSwitch,SymLeds);

initial
        $monitor("%d\trst=%d\tclk=%d\tsw=%d\tleds=%d",
$time,SymRst,SymClk,SymSwitch,SymLeds);

always
        begin
        #5 SymClk         <= ~SymClk;
        if ($time == 10)
                SymRst <=0;
        else
                SymRst <=1;

        if ($time == 100)
                $finish;

        end
endmodule


module  traffic_light(input            InRstSw,
                      input            InClock,
                      input      [3:0] InMouseSw,
                      output reg [2:0] TrafficLights);

parameter RED   =3'b110;
parameter YELLOW=3'b101;
parameter GREEN =3'b011;

reg [2:0] RYG_LED;        

initial
        RYG_LED <= RED;


always @ (RYG_LED)
        begin
        TrafficLights <= RYG_LED;
        $display("TrafficLights=%x",TrafficLights);
        end


always @ (posedge InClock or negedge InRstSw)
        begin
        if(InClock)
                begin
                case(RYG_LED)
                        RED:
                        RYG_LED <= YELLOW;
                        YELLOW: 
                        RYG_LED <= GREEN;
                        GREEN:  
                        RYG_LED <= RED;
                        default:
                        RYG_LED <= YELLOW;
                endcase
                end
        else
                RYG_LED <= RED;
        end
endmodule
        
0
Reply him262 (8) 2/9/2011 10:34:38 PM

See related articles to this posting

On 2/9/2011 2:34 PM, Aldorus wrote:

> internal to the module the variable changes as expected, why isnt
> this represented in the $monitor function' output in module top?
>
> what am I not understanding?

You are assigning to the net SymLeds in two places and there is 
contention between these two assignments. At the top level you have an 
implicit continuous assignment with a value of 0 in the definition and 
the output of the module instantiation also creates an implicit 
continuous assignment. FYI using %b instead of %d shows exactly which 
bits are in contention. Removing the assignment to zero in the 
definition should make things work as expected.

Cary
0
Reply Cary 2/9/2011 11:50:41 PM

On Wed, 09 Feb 2011 15:50:41 -0800, Cary R. wrote:

> On 2/9/2011 2:34 PM, Aldorus wrote:
> 
>> internal to the module the variable changes as expected, why isnt this
>> represented in the $monitor function' output in module top?
>>
>> what am I not understanding?
> 
> You are assigning to the net SymLeds in two places and there is
> contention between these two assignments. At the top level you have an
> implicit continuous assignment with a value of 0 in the definition and
> the output of the module instantiation also creates an implicit
> continuous assignment. FYI using %b instead of %d shows exactly which
> bits are in contention. Removing the assignment to zero in the
> definition should make things work as expected.
> 
> Cary

That worked

Odd thing is the only reason I set it to 0 was to have it initialized for
simulation purposes - thats not sensible since I had a SymRst in play to
set defaults.

Thanks again
0
Reply Aldorus 2/10/2011 12:29:26 AM
comp.lang.verilog 3720 articles. 0 followers. Post

2 Replies
219 Views

Similar Articles

[PageSpeed] 2

  • Permalink
  • submit to reddit
  • Email
  • Follow


Reply:

Similar Artilces:

Monitoring an event monitor
Hello, I would like to monitor an event monitor to make sure that I get an alarm if it's not running. I would like to use SQL statements for this. Is there a way to determine the current status on an event monitor, using SQL? - syscat.events doesn't seem to expose the status of the event monitors. -- Troels "Troels Arvin" <troels@arvin.dk> wrote in message news:hdjjho$g84$1@news.net.uni-c.dk... > Hello, > > I would like to monitor an event monitor to make sure that I get an alarm > if it's not running. I would like to use SQL sta...

CPC128 monitor as DVD monitor
Using the SCART to monitor connection as described here - http://usuarios.lycos.es/putusoft/emucpc/hardwaee.htm#ctm2dvd How good will the image be? It seems a shame to let the monitor go unused if it could be hooked up to a cheapo DVD player for the bedroom, but if it's going to be fuzzy or blurry then why bother getting the soldering iron out. "Raymond Tarded" <bla@h.blah> wrote in message news:d4u74f$glh$1@news8.svr.pol.co.uk... > Using the SCART to monitor connection as described here - > > http://usuarios.lycos.es/putusoft/emucpc/hardwaee.ht...

Monitoring monitors using JVMPI
Hi, I'm trying to monitor threads locking locks using the 'synchronized' keyword and JVMPI. JVMPI provides three contention events for a Java monitor (ENTER, ENTERED and EXITED). It means I get an event only when there's a contention, i.e. another thread is involved. What if I want to know about a single thread entering, leaving or holding a lock? How can I do it using JVMPI and receive an event about it? I saw there is a monitor dump, but that is a specific request that I have to make, whether I would like to be notified about it. If there is no good answer, is there a way...

Monitor
How do you do this in Matlab? I need to monitor the status of a host window via its log file and update a small status text file with a flag value (text) when the status changes. I think I need a matlab function. The input and output for the function is, inputs: type of check - integer file name (text) - name of status file directory (text) - directory path for log file outputs: status (int) - window on or off text - comment on status Could someone give me a code snippet on how to do this? I'm unsure on how to do this in Matlab. ...

Monitor
I am having a problem getting a monitor to work with my Sun Ultra1. I purchased a 13w3-HD15 adapter on ebay. Problem was that the genders where wrong to I had to add a 13w3-Male-Male cable and a HD15 female-female cable to each end to correct the genders. I still get no picture. I thought with an adapter any SVGA monitor should work, I tried two, Viewsonic E70 and a NEC Accusync 90. Neither get a picture. Do I need a SVGA monitor that supports Sync on Comp? Any Ideas? Thanks Darren Hello, P/N 28278 (13W3MH15F) 13W3 Male to VGA 15 Female Two PC monitors that definitely work with this a...

monitor
Hi, My Monitor wouldn't turn on this morning. Well it turned on but the screen remained blank.It's a CTX Ultra. Was OK last night and nothing was altered from shutdown to start up this morning. For the last few days an odd occurrence was the whole screen being sucked in slightly and then back to normal over a second or two. Is it RIP do you reckon? Currently using an old but good AKF85. on 1152 X 864. Regards, Dave. -- D In the interests of product improvement,I reserve the right to foul it up at any time. On 25 Jan 2008 Dave <mail@daveandsylvia.plus.com> wrote: > H...

Monitor
I have seen a IBM P92 Monitor available used for a good price in my area. It has a 13w3 connector on the back. Can anybody tell me before I buy this if it will work with my Sun Ultra1 properly? TIA Darren ...

monitor
My monitor has just given out. Can anyone help with where to get a new replacement please What type do you need or want. I have a few left. EMail me direct wishbringer2001@hotmail.com ...

Monitor
Hi, My 17inch KDS monitor keeps switching from 32 bit to 8bit. The driver is NVIDIA Ge Force2MX/MX 400. When I reboot, it comes up OK then goes dark and comes back up in 8 bit. I have XP withSP3. The problem came before SP3. Any help would be appreciated because this is a pain to keep changing. Ray *<) :o)> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type"> </head> <body bgcolor="#ffffff" text=...