@@ -860,6 +860,83 @@ export defchan bdbool <: chan(bool) (bool?! d; bool?! r; bool!? a)
860860}
861861
862862
863+
864+ /*
865+ * Bundled-data channel for standard memory interface
866+ * Encoding: bottom two bits are control
867+ * 0 = write, 1 = read, 2 = read-modify-write
868+ */
869+ export
870+ template<pint M>
871+ defchan bd_memaddr <: chan(int<M+2>) (bool?! d[M]; bool?! r, w, rw; bool!? a)
872+ {
873+ spec {
874+ /* timing forks */
875+ timing a- : d* < r*+
876+ timing a- : d* < rw*+
877+ timing a- : d* < w*+
878+ }
879+
880+ methods {
881+ /*-- initialize channel, sender end --*/
882+ send_init {
883+ (,i:M: d[i]-),r-,w-,rw-
884+ }
885+
886+ /*-- set output data --*/
887+ set {
888+ (,i:M: [((self >> (i+2)) & 1) = 0 -> d[i]- [] else -> d[i]+ ]);
889+ [self{1..0} = 0 -> w+
890+ []self{1..0} = 1 -> r+
891+ []self{1..0} = 2 -> rw+
892+ ]
893+ }
894+
895+ /*-- finish synchronization --*/
896+ send_up {
897+ [a]
898+ }
899+
900+ /*-- reset part of the protocol --*/
901+ send_rest {
902+ r-,w-,rw-;[~a]
903+ }
904+
905+ /*-- initialize channel, receiver end --*/
906+ recv_init {
907+ a-
908+ }
909+
910+ /*-- get value --*/
911+ get {
912+ [r|w|rw];
913+ self := 0;
914+ (;i:M: self := self | (int(d[i]) << (i+2)));
915+ [r -> self := self | 1
916+ []rw -> self := self | 2
917+ [] else -> skip
918+ ]
919+ }
920+
921+ /*-- finish synchronization action --*/
922+ recv_up {
923+ a+
924+ }
925+
926+ /*-- reset part of the protocol --*/
927+ recv_rest {
928+ [~r&~w&~rw];a-
929+ }
930+
931+ /*-- probe expression on receiver --*/
932+ recv_probe = (r|w|rw);
933+
934+ // no sender probe
935+ }
936+ }
937+
938+
939+
863940template<pbool reset; pint V; pint M>
864941defchan gen_pMbd <: chan(int<M>) (bool?! d[M]; bool!? r; bool?! a)
865942{
0 commit comments