1+ import logging
2+
13from amaranth import *
24
3- from ... import *
4- from . import UARTApplet
5+ from glasgow .applet import GlasgowAppletV2TestCase , synthesis_test , applet_v2_simulation_test , applet_v2_hardware_test
6+ from glasgow .simulation .assembly import SimulationAssembly
7+ from . import UARTApplet , UARTInterface
8+
9+
10+ logger = logging .getLogger (__name__ )
511
612
713class UARTAppletTestCase (GlasgowAppletV2TestCase , applet = UARTApplet ):
@@ -22,3 +28,22 @@ async def test_loopback(self, applet, ctx):
2228 async def test_loopback_hw (self , applet ):
2329 await applet .uart_iface .write (bytes ([0xAA , 0x55 ]))
2430 self .assertEqual (await applet .uart_iface .read (2 ), bytes ([0xAA , 0x55 ]))
31+
32+ def test_multiple_interfaces (self ):
33+ assembly = SimulationAssembly ()
34+ iface0 = UARTInterface (logger , assembly , rx = "A0" , tx = "A1" , parity = "none" )
35+ iface1 = UARTInterface (logger , assembly , rx = "B0" , tx = "B1" , parity = "none" )
36+
37+ assembly .connect_pins ("A0" , "B1" )
38+ assembly .connect_pins ("B0" , "A1" )
39+
40+ async def write_testbench (ctx ):
41+ await iface0 .set_baud (9600 )
42+ await iface1 .set_baud (9600 )
43+ await iface0 .write (b'Hello' )
44+
45+ async def read_testbench (ctx ):
46+ self .assertEqual (await iface1 .read (5 ), b'Hello' )
47+
48+ assembly .add_testbench (write_testbench )
49+ assembly .run (read_testbench , vcd_file = "uart_multi.vcd" )
0 commit comments