Aiming for a clean P1V compile? (and anyone added a simple UART?)
Cluso99
Posts: 18,069
Postedit: Change heading
Has anyone added a simple UART to their P1V?
And has anyone done a clean compile of the P1V?
Has anyone added a simple UART to their P1V?
And has anyone done a clean compile of the P1V?
Comments
Not sure what you mean bu a "clean" compile?
Do you mean no warnings in the compilation report?
P.S. Not yet on the UART question.
A UART in COG is regarded by many as a terrible waste of a 32 bit processor and 2K of RAM.
If you can build a P1 for FPGA why not add a little logic for a UART, it's no worse an idea than the Prop having counters or video generators.
In fact arguably the Prop would be better off with having hardware UARTs than video generators.
@Cluso
How are you thinking this should be done?
Should there be one UART per COG in the manner of video hardware? With some special registers in COG space. Perhaps replacing the video registers.
Should there be a UART as a shared HUB resource.
Or instead of using registers would there be UART instructions like the lock instructions?
They were very easy to use and fast!
For the UART, I just want a simple single UART. Not a standard UART with error flags looking like a 16450 style, but like the pair Chip did in the P2.
I intend to remove the Video so I can use those registers for Tx and Rx.
I am going to compile a single cog with the hub available at full cog speed, and available as extended cog ram too. By changing JMPRET and TJ/DJ to relative and making the pc 14 bits (long address) I can execute from extended cog / hub ram.
Hence my need for a simple UART to communicate with th PC.
I haven't had any problems (currently on Quartus II 14.1 for Windows). Because I didn't like timing warnings, I wrote an SDC file for the DE0-Nano (I don't have a DE2-115 and the Cyclone V on the BEMicro CV is tricky) that lets TimeQuest do its thing without warnings. That file is currently pushed to jacgoudsmit's P1V fork (https://github.com/jacgoudsmit/P1V).
What kind of compile errors are you seeing?
Since I am going to be playing around with potential timing problems I want to start with a clean compile.
So thanks... I will download and compile.
These .sdc files are huge. Some hundred lines of code....
True. And it's not very flexible, at least for those who want to add or remove cogs and or counters. Of course, it's all just tcl, so it's possible to write it a bit more generically. But I won't be getting around to that any time soon...
I wonder how hard it would be to extend the functionality of the various registers to use it as a proper UART. After all, there are quite a number of unused bits in the video configuration registers...
===Jac
We have used the VGA to send out clocked serial databits in the P1. It would have been nice to be able to input them serially too. It probably wasn't on Chip's mind when he designed the VGA.
IIRC the video used quite a bit of the fpga, hence I cut down the VGA to only 1 or 2 cogs. I would think in reality we could set cogs say cogs 0 & 4 to have VGA, and cogs 1,2,3,5,6,7 to have UARTs. Then these cogs have access to the VGA registers and WaitVID instruction for UART registers and instructions.
Jac,
I downloaded the clean master from git. Nice job. It still reports 36 warnings although I think most are not relevant.
I presume the top.tdf is the place to change to increase the clock... I would like to try 96MHz (USB) and above. Anyway,I will just give it a try.
I've been thinking something similar Jac. You could use FRQA/B to set the baud rate, and PHSA/B to read or write UART data. The CTRA/B config register, upon read, could identify how many bytes are in the RX buffer. The buffers themselves can be hidden behind the PHSA/B registers and be of the required depth.
Hopefully its just a matter of substituting cog_ctra and cog_vid_. We could make other peripherals in a similar way too, it would make them easy to substitute.
I've been thinking of changing the video Verilog to reduce the video hardware too, but I would probably implement some sort of automatic allocation mechanism, linked to write-operations to any video register. Whichever cog is the first to write to any of the video registers, gets the video; when the cog stops, the video hardware is "freed" again. That way most existing SPIN/PASM software will still be compatible (as long as you don't run too many video cogs obviously). The allocation would need 8-to-1 multiplexers for each video register of course, and I don't know what the consequences would be for LE usage.
Another option is to redesign the video hardware so that each pin group (0-7, 8-15, 16-23 and 24-31) has its own video hardware, instead of assigning video hardware to the cogs. This should save at least half of the video hardware but might be tricky to implement, in case of conflicts between cogs that are trying to control the same pin group.
Thanks! I didn't make any changes to the code in my P1V github repo, I just reorganized it so that it would take less work to implement changes and port them between targets. The warnings are probably the same (timing) warnings of the original code. I've only done minimal testing because I didn't have a lab to hook up my BeMicro CV to anything worth really running an application.
I've been working on other projects and I moved from Arizona to California last month, so I haven't had much time for P1V...
===Jac
By adding the files "top.tdf", "tim.tdf", "dig.v" to the project in Quartus removes 3 warnings.
Project/Add Files/Files/Add (top.tdf, tim.tdf, dig.v)
There must be a way to have these files included in the project without the need to modify the project in Quartus.
Does anyone know how to solve this ???
Here are the changes to hub_mem.v to remove 2 warnings (add the `ifndef... and `endif lines)
Here are the remaining 11 warnings (note the hub_mem.v line number is incorrect) Does anyone know how to remove any of these warnings ???
BeMicroCV.qsf
DE0-Nano.qsf
DE2-115.qsf
after these line(s) and the fix above, we are now down to 0/11 warnings without the need to add files to the project.
It took 16m33s - ugh!
There were 6 errors and 17 warnings.
2 errors complained about a missing BeMicroCV.sdc file and 4 errors were timing errors.
Can I just copy the DE0-Nano.sdc file???
Here are the errors and warnings
Unfortunately, no. Cyclone IV and Cyclone V have very different PLL declarations.
It is not the fastest as it is both Rx and Tx, but it may be of use as it is a complete Verilog module with a Github repository.
http://opencores.org/project,osdvu
And here is a link to another coder with explanation.
http://www.fpga4fun.com/SerialInterface5.html
And a TX only configuration.
http://ece301.com/fpga-projects/52-uart-txd.html
And a RX only configuration to mate with the above TX only
http://ece301.com/fpga-projects/57-uart-rxd.html
I haven't yet tried any as I am awaiting the arrival of my first FPGA devices. But I also tend to feel that using a whole cog for serial i/o may be a bit wasteful. These may allow one to get an 'outside' UART.
He has done an excellent job of integrating the Verilog code for all the various Altera Development boards -- Terrasic or BeMIcro.
https://github.com/jacgoudsmit/P1V
thanks... jac
You really seem to have mastered Quartus II and the P1V. We can all learn something from this repository.
Thanks for your kind words, but at this time I know barely enough of Verilog and Quartus to be dangerous. And I don't know hardly anything about the Xilinx ISE tools because I don't own any Xilinx hardware (yet).
I don't know if a clean compile of P1V will ever be possible; Quartus is very picky (which is a good thing!) and it looks like it's simply impossible to do some things without generating warnings. And I could use any help I can get!
===Jac
Maybe not absolutely clean. But all the code that Parallax links to is older, and their .zip that includes the BeMicroCV doesn't work.
You are still way ahead of me as I just got started with Quartus II, Verilog, and VHDL. At the very least, I don't have to bother with soldering to build something sophisticated.
In the propeller world, you would build the uarts in cogs in software. But in the vhdl world, a uart is a component that is easy to drop into the code, and easy to add more with just a few lines of vhdl each time, so it makes more sense to add vhdl, and to keep cogs free for other more complex and flexible tasks.
In the strange hybrid world of a propeller emulated on a fpga, well, anything goes, and it may well be better to add things in vhdl - eg SPI, vga drivers, external memory management units, external memory, and still have 8 cogs free.