Re: Midterm Solutions -- from Winter 98/99 Term2

Ed Casas (edc@ece.ubc.ca) Sat, 28 Oct 2000 17:50:43 -0700


Date: Sat, 28 Oct 2000 17:50:43 -0700
From: Ed Casas <edc@ece.ubc.ca>
Subject: Re: Midterm Solutions -- from Winter 98/99 Term2

> In the architecture, signals "count," "next_count," and > "count_plus_1" are declared as 4-bit unsigned vectors. YET, in > the few lines after the "begin," count is directly equated with > a 9 (integer value). This code, as it is written on the > solution set, thus, does not compile. > > Intead of: > > count_plus_1 <= 0 when count = 9 ... > > it should be count_plus_1 <= 0 when count = conv_unsigned(9,4) ... This solution has a couple of syntax errors, but your analysis is not quite right. You need to look at the std_logic_arith package to see whether the = (equals) operator is defined for an unsigned value on the left and an integer value on the right. The summary sheet for the IEEE std_logic packages which you can get from the course web page at: http://casas.ece.ubc.ca/379/1164pkg.pdf shows that the `=' operator is defined for these argument types. You can verify this by looking at the source for the std_logic_arith package which, for a default MaxPlusII installation, is at: c:\maxplus2\vhdl87\ieee\arith.vhd which has the following entry: function "="(L: UNSIGNED; R: INTEGER) return BOOLEAN; The real problem is that the type of the value being assigned (the integer constant 0) does match the type of the signal it is being assigned to. The corrected solution would be: -- next value in count count_plus_1 <= conv_unsigned(0,4) when count = 9 else count + 1 ; Thanks for pointing this out. -- Ed Casas edc@ece.ubc.ca http://casas.ece.ubc.ca +1 604 822-2592