From f4f129a75208ccf5d6a19b1cb81c56d4d95fd61f Mon Sep 17 00:00:00 2001 From: Ben Bridle Date: Mon, 30 Sep 2024 12:28:24 +1300 Subject: Make Bedrock parametric over devices The core Bedrock struct is now parametric over individual Device structs, rather than over a single DeviceBus. This change was made so that devices can be implemented separately to one another. The implementation of the evaluate method has also been changed to make it potentially slightly more efficient, by replacing pop-then-push combinations with get operations. --- src/bedrock.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/bedrock.rs (limited to 'src/bedrock.rs') diff --git a/src/bedrock.rs b/src/bedrock.rs new file mode 100644 index 0000000..19ccae6 --- /dev/null +++ b/src/bedrock.rs @@ -0,0 +1,20 @@ +use crate::*; + + +pub struct Bedrock { + pub mem: ProgramMemory, + pub wst: Stack, + pub rst: Stack, + pub dev: DeviceBus, +} + +impl Bedrock { + pub fn new(device_bus: DeviceBus) -> Self { + Self { + mem: ProgramMemory::new(), + wst: Stack::new(), + rst: Stack::new(), + dev: device_bus, + } + } +} -- cgit v1.2.3-70-g09d2