$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 3755 articles. 0 followers. Post

2 Replies
280 Views

Similar Articles

[PageSpeed] 8


  • 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
Ok, this may not be the best place. But... Im looking at getting a new mointor. First off, what size would be best? I can afford either a 17" or a 19", about the same price. �135. Both can do 1280. The 19" at 90Hz, and the 17" at 85Hz. The 17" is .24 dot pitch, and the 19" has a .26 dot pitch. And they are both truly flat, apparantly. Logic says go for the 19". Most bang for buck, but my mate insists you cant get a decent 19" until you hit �200, and that I should plump for the 17". What do you guys/gals think? Will 1280 on a 19" be too bi...

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=...

Set front panel size to fit different monitor ( 2 monitors-pattern to 1 monitor-pattern)
Hello, Everybody, I have here some questions about front panel size.At first I have create my LabVIEW programs with 2 monitors and run them with 2 monitors, because of this reason I have created a huge front panel with many objects.But sometimes I will run the program only with 1 monitor, the problem is, the front panel is too big, I can not see the front panel with all objects completely on one monitor! I know, I can scroll aroud it, but I don�t like this way. I would like to set the front panel size automatically to fit the window ( to differenz window sizes or resolutions), how can I do tha...

View multiple monitors from a single monitor
Hello all. I need some help finding a remote software that will allow me to view multiple monitors (2-3) from my single monitor. Is there such an application out there? I currently have RADMIN and can remote and view one monitor on computers but we have users in our office using 2 or 3 monitors. I am only able to view the far left monitor when remoting in. Any advice would be greatly appreciated. ...

Searching monitor card for 2 (!) monitors
I would like to use 2 monitors simultaneously at once to have a bigger desktop. Can someone recommend me a good monitor card with two such monitor ports ? It need not a high performance since I am not playing video games. Tom "Thomas Jerkins" <tomjerk@hotmail.com> wrote in message news:cjir5v$3ga$01$1@news.t-online.com... > I would like to use 2 monitors simultaneously at once to have a bigger desktop. > Can someone recommend me a good monitor card with two such monitor ports ? > > It need not a high performance since I am not playing video games....

Monitors
Can standard Multisync monitors be adapted to the standard 520 and 520 STFM series of computers inexpensivley? TIA Usually. The ST 13-pin video port outputs analogue RGB, together with separate vertical and horizontal synch pulses (it also SUPPOSEDLY outputs composite synch, but in actual fact it outputs composite video) If your monitor has a composite synch pin only (such as the microvitec "cub" series) you'll need to combine the vertical and horizontal synch pulses - I think this can be done with just a discrete OR gate, which you can make with two diodes and a resistor. Th...

Monitor for G5
Will a standard analog monitor designed for an intel type PC work with a Mac G5? I hope this isn't a stupid question, but I'm not familiar with Mac hardware. You see, I'm considering helping out by daughter, in college, with a new G5. We have some extra 17" monitors at work as we've been relpacing these with LCD's. While I know she wants an Apple Cinema display, I'd rather spend the limited dollars on the CPU now and let her add a monitor later if the PC type LCD monitors will work. In article <10b91440.0402081021.5225d1b2@posting.google.com>, Larry <l...

Using laptop monitor to replace BARCO monitor
Hi, I have a system which connects to BARCO monitor CD651 as display (using BNC). I am wondering if the display breaks down and I do not have a spare BARCO monitor, can I use a laptop screen as a stand in? My limitation is that I cannot add additional hardware or software to the system that support multi-monitor functions as I do not have the authority to modify the system. My only input is the video signal that is originally supplied to the BARCO monitor. Is there any hardware or software available that I can install in the laptop to make it as a secondary display? Rgds. ljj24@hotmail....

Monitoring bandwidth usage
With a lot of help from my friends I wrote a bash script that displays the number of kilobytes being uploaded & downloaded every second via my eth0 internet connection. The ouput looks like: $ monitor 10.8 k/s 2.3 k/s 22.3 k/s 1.3 k/s 12.1 k/s 3.1 k/s .... The logic of the script goes something like this: init: invoke netstat to retrieve initial packet counts do forever: invoke netstat to retrieve next packet counts compute kilobyte delta = packet delta * MTU / 1024 display results This works fine and displays plausible results, but they seem to differ somewhat (+20-30%) from an e...

Which monitor?
What would you buy for MCAD software???? * Two 19" monitors or *One 22" monitor How SW works in dual monitor mode?? And: * LCD or CRT?? Which is better option ??? Thx Jaro I have one 22" Trinitron Monitor CRT running a 1600x1200 Resolution...I have more than enough Real State to go around a few times. I love this monitor It's great for running SW and even better when playing games! Regards, Scott "Jaro735" <jaro735@op.pl> wrote in message news:bfrqbm$o82$5@news.onet.pl... > > What would you buy for MCAD software???? > * Two 19" mo...

Monitoring
Hi , Is there a way/tool in Sql Server 2000 SP3 to monitor all activities going on in the Database ? For example, I first create an empty database. Then I have an ERWIN generated DDL to create all views and tables. After that, I have INSERT scripts that populate all the base tables. What I want to monitor is success or failure for each script. Thanks, N. N (N@N.COM) writes: > Is there a way/tool in Sql Server 2000 SP3 to > monitor all activities going on in the Database ? > For example, I first create an empty database. > Then I have an ERWIN generated DDL to create >...

What is Monitor?
I think Monitor is a higher concept than that of lock primitives such as mutex, semaphore, critical section. I have heard Monitor was invented as a part of OS functions. I sometime come across Monitors, but their functions are somehow different. I would like to know what is Monitor, what are main differences of Monitor from the lock primitives, and what purposes is Monitor used for. I would like also to know whether Monitor is a singleton or not for a process in which multiple threads run ? [ See http://www.gotw.ca/resources/clcm.htm for info about ] [ comp.lang.c++.moderated. ...

monitors
what would be the best type of monitor that i could get to stop the glare of the sun when it comes in my window. speirsyboy@hotmail.com (martin speirs) wrote in message news:<a6866bcc.0312010337.344b98ce@posting.google.com>... > what would be the best type of monitor that i could get to stop the > glare of the sun when it comes in my window. instead of buying a new monitor have you tried an anti-glare screen that you can get from almost any computer parts store? I think they cost alot less than a new monitor. hope this helps ...

Monitor Calibration, Photshop Workspace, LCD monitor
I've read somewhere on the web that LCD monitors have a linear gamma equation so it is not really necessary to use Adobe Gamma Loader: is this true? My ATI graphic card has as usual a Color management tab in its properties: is it better to use this one and not load Gamma Loader at startup, or the contrary? Or should I disable both? My digital camera CANON EOS 300D/REBEL can use either sRGB (customizable) or AdobeRGB (not customizable): which one is better? When shooting in RAW mode it uses AdobeRGB. If using sRGB for the camera, should I set sRGB as Photoshop worspace or AdobeRGB....

Monitors
Apologies for bringing this topic up again but but i am still unsure about MDFs and i am certain i don't have the best set up MDF for the monitor i am using with is a 15" LCD Samsung SyncMaster 152V, Castle supply with the Iyonix an MDF for the SyncMaster 172V which i have been using but i guess this is for a 17" monitor ? (hence the 152 and 172 numbers?) i have been looking at various MDFs to try and understand how they work but drawn a blank parts of them make sense but parts of it don't In short i need a MDF that is for my monitor and also will be able to run games such...

What Monitor?
I have just purchased a new PC, spec below and am trying to determin the best monitor for maximising the graphics potential of the machine. Would a crt or TFT be better and if TFT would it be better to have th higher resolution of 20" TFT or the faster response time of a 19"TFT? SPEC: AMD Athlon 64 FX57 2GB Ram 300G HD Nvidia's 7800GTX GFX card. Ta -- brianbru ...