I wanted to introduce process-local variables in RHDL, and I tried a lot of different ideas, but finally settled on this fairly simple syntax (which was also easy to implement):
process(clk) {
#process-local vars here
c = 0 #c is now local to the process
process_behavior { #process behavior here
if clk.event and clk == '1'
puts "rising edge of clk"
if reset == '1' || c== (mod-1)
c = 0
else
c = c+1
end
count <= c
end
}
}
The variable c is local to this process block. The only drawback is the process_behavior which is now needed. I may end up calling it something else. I'd like to be able to use begin instead, but it's taken. Maybe just behavior would work. Whatever I end up calling it, if the process_behavior call and block are missing, then an exception is raised (every process should have some behavior defined).
To explain a bit further what's happening in the code above: The c=0 just before the process_behavior call gets run just once while the code inside of the process_behavior block gets called every time the clk signal (in the sensitivity list for this process) changes value.