P
Paul Taylor
Guest
Hi,
I have been playing around with a HDL + associated tools, and want some
feedback. I have designed the HDL to be relatively terse but still
hopefully clean and clear.
Basically what I want to know is, from a viewpoint of people who know
vhdl, does the following code make any sense? i.e. do all the contructs
look impenetrable, or can you hazard a guess at what they are doing? The
code below is in fact based on the vhdl code found here:
ftp://ftp.xilinx.com/pub/applications/xapp/xapp199.zip
(in the vhdl_selfchecking directory of the zip)
#
# @Title Stopwatch
# @Description A stopwatch with tenths, seconds, and tens of seconds.
# @Port tenths Tenths of seconds, inverted one-hot decoded
# @Port ones Seconds decoded to drive a seven segment display
# @Port tens Tens of seconds decoded to drive a seven segment display
#
module StopWatch() {
inport clk, reset, clk100ms; nStartStop;
outport tens[%7], ones[%7], tenths[%10];
node startStop = !nStartStop;
reg sm[] = { # controlling state machine
0 when reset;
: tenthsCount.rst = 1; onesCount.rst = 1; tensCount.rst = 1; next;
: next when startStop;
LOOP: tenthsCount.inc = 1 when clk100ms; next when !startStop;
: tenthsCount.inc = 1 when clk100ms; next when startStop;
: next when !startStop;
: LOOP when startStop;
}
reg tenthsCount[%4] = {
node rst, inc, rollOver;
0 when rst;
0 when inc & (tenthsCount == 9) with rollOver = 1;
next when inc;
}
reg onesCount[%4] = {
node rst, rollOver;
0 when rst;
0 when tenthsCount.rollOver & (onesCount == 9) with rollOver = 1;
next when tenthsCount.rollOver;
}
reg tensCount[%4] = {
node rst;
0 when rst;
0 when onesCount.rollOver & (tensCount == 5);
next when onesCount.rollOver;
}
const SEVEN_SEG_DECODE[10] = { 0x79, 0x24, 0x30, 0x19, 0x12, 0x02, 0x78,
0x00, 0x10, 0x08 };
tens = SEVEN_SEG_DECODE[0 .. 9] when tenthsCount == 0 .. 9;
ones = SEVEN_SEG_DECODE[0 .. 9] when onesCount == 0 .. 9;
node tenthsDec[%10] = 1 << 0 .. 9 when tenthsCount == 0 .. 9;
tenths = !tenthsDec:
}
Thanks + regards,
Paul.
I have been playing around with a HDL + associated tools, and want some
feedback. I have designed the HDL to be relatively terse but still
hopefully clean and clear.
Basically what I want to know is, from a viewpoint of people who know
vhdl, does the following code make any sense? i.e. do all the contructs
look impenetrable, or can you hazard a guess at what they are doing? The
code below is in fact based on the vhdl code found here:
ftp://ftp.xilinx.com/pub/applications/xapp/xapp199.zip
(in the vhdl_selfchecking directory of the zip)
#
# @Title Stopwatch
# @Description A stopwatch with tenths, seconds, and tens of seconds.
# @Port tenths Tenths of seconds, inverted one-hot decoded
# @Port ones Seconds decoded to drive a seven segment display
# @Port tens Tens of seconds decoded to drive a seven segment display
#
module StopWatch() {
inport clk, reset, clk100ms; nStartStop;
outport tens[%7], ones[%7], tenths[%10];
node startStop = !nStartStop;
reg sm[] = { # controlling state machine
0 when reset;
: tenthsCount.rst = 1; onesCount.rst = 1; tensCount.rst = 1; next;
: next when startStop;
LOOP: tenthsCount.inc = 1 when clk100ms; next when !startStop;
: tenthsCount.inc = 1 when clk100ms; next when startStop;
: next when !startStop;
: LOOP when startStop;
}
reg tenthsCount[%4] = {
node rst, inc, rollOver;
0 when rst;
0 when inc & (tenthsCount == 9) with rollOver = 1;
next when inc;
}
reg onesCount[%4] = {
node rst, rollOver;
0 when rst;
0 when tenthsCount.rollOver & (onesCount == 9) with rollOver = 1;
next when tenthsCount.rollOver;
}
reg tensCount[%4] = {
node rst;
0 when rst;
0 when onesCount.rollOver & (tensCount == 5);
next when onesCount.rollOver;
}
const SEVEN_SEG_DECODE[10] = { 0x79, 0x24, 0x30, 0x19, 0x12, 0x02, 0x78,
0x00, 0x10, 0x08 };
tens = SEVEN_SEG_DECODE[0 .. 9] when tenthsCount == 0 .. 9;
ones = SEVEN_SEG_DECODE[0 .. 9] when onesCount == 0 .. 9;
node tenthsDec[%10] = 1 << 0 .. 9 when tenthsCount == 0 .. 9;
tenths = !tenthsDec:
}
Thanks + regards,
Paul.