Thanks for the replies - that's not my code, by the way, but an example I found on the interweb somewhere. The use of 'always @*' confused the heck out of me - as you know asmi, I'm a learner when it comes to HDL and suddenly walking into code that is combinatorial instead of synchronous was a bit of a shock.
I had to do some reading on it and still don't really understand it.
I don't suppose there's any reason I couldn't re-write the key2ascii.sv code and make it synchronous? It'd certainly sit a lot better with my understanding, if nothing else.
Getting these two modules working is part of the task, but I've also found a major issue with handling the IO request from the Z80 host to get a character that has been typed.How it should work is that
keyboard.sv gets the keycode when a key is pressed, passes it to
key2ascii.sv which decodes it into an 8-bit ASCII character value and passes that to
Z80_bridge.sv, which updates the PS2_CHAR register with that value. PS2_CHAR remains unchanged, until the Z80 host reads it via an IO operation, or another ASCII character is sent from key2ascii.sv. I have code on the Z80 polling the PS2_CHAR register constantly - if the returned value is 0x00, it does nothing, otherwise it prints the character to the serial console. Once the character is read, Z80_bridge.sv resets PS2_CHAR to 0x00 again to prevent repetition. This should all happen so quickly there's no chance of a repeated (or held) keypress overwriting the last one before it's read.
@BrianHG, if you're reading this, I'd certainly appreciate your critical eye on the code in Z80_bridge.sv. I think I'm messing up the timings on the IO cycle and either not getting the data onto the Z80's bus in time, or not holding it on the bus long enough for the Z80 to read, as
I'm getting a constant stream of 'x's in the console, with nothing attached to PS2_DAT and PS2_RDY grounded on the Z80_bridge's inputs, so this problem has nothing to do with the PS2 modules, ironically. It's probably some stupid mistake I've made in the code when I created the code to manage an IO read.
The Z80_bridge should be returning 0x00 if there is no character value in the buffer,
which should be the case all the time as keyboard.sv or key2ascii.sv modules aren't connected to it and the PS2_RDY input is grounded.
If you're using Verilog code why are you messing with the schematic entry? Just use either Verilog or VHDL for the top level too, it ends up being much simpler and easier to work with.
What you see is just a small part of a very complicated (to me, at least) HDL project to handle video graphics and interface that with a Z80 via an 8-bit parallel interface. I find using schematic entry makes it all much easier to understand at a glance - I'm not experienced with this stuff at all and am very much a learner.