[ Content | Sidebar ]

VHDL Compiler Updates

May 5th, 2017

It’s been a long time since I wrote anything about the VHDL compiler and simulator I’m working on, nvc, but I am still developing it, albeit at a slightly slower pace than before.

Since the last update I’ve started making stable releases, and yesterday I released version 1.2.1. Actually I think most people are better off using the master branch: one thing I’m really proud of is the coverage of the regression tests, and they run on every commit using Travis so it should always be stable enough for everyday usage. The “stable” versioning is really to satisfy the requirements of packagers. For instance it is now part of Homebrew for OS X.

The big change in the last year has been the removal of the old hacky constant folding pass and replacing it with one based on the “vcode” intermediate code layer that I wrote about before. The old version used to walk over the AST nodes and attempt to collapse them into a simpler form by evaluating expressions and even evaluating function calls. Unfortunately this was often buggy and sometimes didn’t match the run-time result the code generator would have produced. Now constant folding is done using the same AST-to-vcode lowering pass the code generator uses, to generate vcode “thunks” for compile-time constant expression. These are then evaluated using a new vcode interpreter. This now means almost all side-effect free functions with constant arguments will be folded at compile time. Even those with complex looping, recursion, memory allocation, etc.

Unfortunately this rewrite took way longer than expected, partly due to not having much time to work on it, and partly because all the dependencies into the rest of the code got very complex.

Apart from that I’ve fixed a lot of bugs. And this means you can simulate some quite complex designs in it, for instance the J-Core open source SuperH CPU clone.

Xingping to Yangdi

April 30th, 2017

So after I had a fun day out in Xingping I decided to go back there the next day and see how far I could get along the river. If you look around on the internet there’s various references to a classic hike from there to another village called Yangdi along the most scenic section of the river but they also say it’s now “impossible” or “unsafe”. This is nonsense, as it’s totally doable as of March 2017 although requiring a bit of luck and a small amount of adventurousness. I’ve tried to write some instructions below in case anyone else wants to try it. It’s by far the best hiking I’ve done in Asia, and unlike all the tourists packed onto the boats, you’ll have time to appreciate the scenery.

It’s probably useful to be able speak some Mandarin as you’ll need to get someone to help you across the river at one point. Or you could just try gesturing wildly.

The first part is really easy. Just head out of town past the “20元 note scene” and follow the road until it starts to curve away from the river. Then you can drop down onto the beach and there’s a well maintained path following the shoreline.

Follow the path for about three miles and you’ll come to a scenic spot called “nine horse fresco hill”. On the other side of the river is a small village and a ferry to take you across. Just get on and pay the guy 10元.

In the village there are some stalls where you can buy fruit but not much else. Just follow the road through and out the other side where you’ll see a large grassy area by the river down below. Scramble down some rocks and the path should be fairly obvious (it’s where those people are walking below).

Follow the path along the river for another two miles or so until you hit a dead end and you’ll need to double back a little way and take a more inland route (check my map above). This bit has the best scenery, I stopped every 30 seconds to take a photo.

On the stone is the local tourism slogan 桂林山水甲天下 “Guilin’s scenery is first under heaven”. It was around this point I made friends with a very friendly old lady who apparently walked this way every day to sell oranges. Not a bad job eh. It was her 70-something birthday.

She insisted on accompanying me for the next mile or so to the village where she lived which turned out to be really useful as the reason for the internet saying the route was impassable soon became clear: you need need to cross the river again at this point but the only official ferry sank a few years back, it’s remains were rotting on the riverbank. After I told her where I was going the orange selling lady introduced me to her friend, an old guy with the sketchiest looking raft ever. He took me to the other side for a small fee.

I rather suspect this a profitable business for him since the ferry sank, as he seems to just hang out by the old ferry landing. You can probably haggle a bit on the price.

The path on this side is a bit overgrown but should be easy enough to find. Follow it for a while and you’ll come to a small tranquil village with some very elegant lanes. This isn’t Yangdi though so just walk out the other side of the village and take the path over the rope bridge (I asked for directions at this point).

Pass these small farms and you’ll eventually come to another operational ferry. Ride that back to the other side and you’ll reach the destination. The bus back to Yangshuo takes an hour or so and is quite scenic itself. Epic day out!


April 23rd, 2017

XingPing (兴坪) is the place I should have stayed instead of YangShuo. It’s only 45 minutes away by bus, but it feels like a totally different place. Much quieter and less commercialised.

The town is right on the most scenic section of the Li river. In fact, the scene on the back of the 20元 note is a 15 minute walk out of town. There were, however, quite a few competing “official” viewing platforms, so I don’t really know if this is the right one.

A Final Samsung Q320 Update

April 23rd, 2017

You almost certainly don’t remember but back in 2009 I published a series of articles detailing by travails getting Linux to run smoothly on my then-new Samsung Q320 laptop. Well you’ll be pleased to know that eight years on I’ve finally solved all my remaining issues:

  • The fan randomly spinning up and down
  • The “always-powered” USB port not working
  • General sluggishness

The first two can be fixed by downloading the 06LH BIOS update from July 2010. Maddeningly this can only be installed from Windows. To fix the third problem I swapped the original magnetic disk for a modern SSD (really easy), and at the same time temporarily installed Windows 10 and applied the BIOS update. Then I dd-ed my old disk over the SSD using a USB-SATA adapter.

I’m really happy with the result. Running Debian Stretch everything Just Works and with the SSD it’s pretty speedy. At the moment I’m using it whenever I go home to visit my parents.


April 14th, 2017

So Yangshuo is a town in the countryside just south of Guilin which was probably really nice 20 years ago but which has been commercialised so much it’s easily the tackiest place I’ve been in China. Think hordes or persistent touts that target white tourists, loads of Western junk food, “Irish” pubs, etc. etc. Not my kind of place. If I’d known before I went I would have stayed in one of the smaller villages nearby. Although the lady who ran the small hotel I stayed at was really friendly, so not all bad.

Pizza Hut, KFC, McDonalds, what more could you want?

There are some natural attractions south of Yangshuo that are worth a visit, but as you might expect they are way over developed. It didn’t really help that the day I went was very grey and gloomy.

Old banyan tree

The first one is this 1000 year old tree called, descriptively, “Big Banyan Tree”. Bit spooky and Harry Potter-ish.

Half moon hill

This one is called Half Moon Hill. Climbing up is good fun. At the top were some enthusiastic old ladies selling water trying to justify their ridiculous prices because they had to carry it all the way up. Hmm.


April 2nd, 2017

Where to next on my off-season travellings?! Well I went south and west to Guangxi, and its capital Guilin. It’s mainly famous for the strange rock formations dotted around the city, but there’s actually much better examples in countryside to the south around Yangshuo. The one below is supposed to resemble an elephants trunk, although that was bit lost on me.

Elephant trunk hill

Guilin is definitely high up on the list of China’s top tourist attractions. It’s not totally clear to me why though, it seems a bit over-developed and the sights are just so-so yet eye wateringly expensive. There’s a Chinese phase 一般般 which seems appropriate. Anyway this means there’s an awful lot of English speaking touts, especially around the bus and train station, which came as a bit of a shock to me after a week in Guizhou which had none of that. They are annoyingly persistent.

World’s tallest copper pagoda

My favourite attraction was actually this, the world’s largest copper pagoda. And, I’m fairly sure, the world’s only copper pagoda. It really is all made of copper. Impressive. You can go outside and walk around every level, which is rather good fun. And the only way to access it is via an underwater tunnel from beneath another pagoda (the one I’m standing in). Oh and it’s the only pagoda in the world with an elevator to the top. Um…

Guilin scenery

But the best scenery in Guilin is not in the city itself, it’s what you can see in the distance from the top of the city’s scenic spots. The mountains in Guangxi really are very exotic. But more of that later, including a fun hiking adventure.


March 30th, 2017

Last stop on my little Guizhou adventure is 镇远 Zhenyuan near the border with Hunan. It sometimes gets called “Zhenyuan Ancient Town” but the taxi driver from the train station assured me it really isn’t that ancient. But it’s still a lovely picturesque place, and just the right amount of touristy. That’s Chinese tourists mind you, during my whole stay in Guizhou I didn’t see any other westerners, or even speak any English which was pretty good for my Chinese practising. February is very off-peak though.

There’s no high speed train here: you have to either take the old low-speed train on the Shanghai-Kunming route or a long-distance bus. Either way you’ll have an interesting cultural experience, and I like the feeling of remoteness.

Old part of Zhenyuan

The older part of town is across the river from the part with the train and bus station, and the waterfront above is quite photogenic.

On the day I arrived there was quite a dramatic change in the weather and the temperature plummeted to around five degrees. Who’d have thought it would be this cold so far south?! Turns out temperature is function of altitude and season as well as latitude…

Miao Great Wall

First thing I did was climb up the big mountain behind the town. On top is this Miao “Great” Wall. Not sure what’s “great” about it, it mostly resembles a regular city wall. Anyway it’s fun to walk along and the mountain scenery is very pretty. After a while the wall falls away into ruins and path quickly disappears. It might be possible to venture further into the mountains but it looked pretty wild.

Panorama of Zhenyuan town

On the other side of the river is a tourist attraction called 青龙洞. I thought 青 meant a greeny-blue colour but it’s translated here as “Black Dragon Cave”. I also thought it might be a cave, but it’s not, it’s a temple built into the side of the mountain. It’s really good fun spending an hour or so exploring the little grottoes and pavilions. And as you get higher you get some excellent views over the town.

Qinglong Dong temple

My favourite place in Zhenyuan is actually just out of town, called 龙池 or “Dragon Pool”. The titular pool is at the end of 4km-ish walk through a river valley. You can get there by taking local bus number 7 from the western end of the old street. Just ride it all the way to the “scenic area” final stop.

Path to the Dragon Pool

The trail itself is quite good with some impressive cliffs and waterfalls. I didn’t see any wildlife though. All the while you’re following the river upstream until it suddenly stops at this perfectly still pool which water flows out from but not in to?!! 😮

Dragon Pool – it really is this colour!

No idea how deep it is but it’s incredibly clear and you can see dead branches and other things standing vertically up waaaaay down. I guess the water must come from inside the earth somewhere. Weird.

Anyway I really liked Zhenyuan. I would go back, but probably in summer or later in spring. Because there were no boats operating I missed out on seeing the impressive sounding “Wuyang Three Gorges” down the river. Although that might be named along similar lines to the “Miao Great Wall”. 😛

Langde Miao Village

March 24th, 2017

Here’s another Miao village, called 郎德 “LangDe”, but it’s a lot smaller and quieter than XiJiang which I visited the previous day. Really it’s more of a hamlet.

According to the Lonely Planet guidebook you can only reach here by taking the 凯里 Kaili to 雷山 Leishan bus and hopping off on the main road at the “lower” village and then walking 2km up the valley to the “upper” village. This isn’t true as there’s a local hourly minibus that goes direct to the village from the same bus station in Kaili and takes a very picturesque, if mildly terrifying, back country route through the mountains. The return schedule isn’t clear and is possibly just “when the driver feels like it”, but I certainly managed to get one back around 16:30.

凯里 Kaili was the town where I was staying these few days, by the way. There’s not a lot in the town itself, but the transport links are good, there’s some interesting night markets, and a free “minorities museum” for rainy afternoons.

You can hike up the mountain behind the village via an incredibly steep and slippery path. The scenery looked almost alpine, apart from all those 梯田 terraced fields.

Some of the houses have been turned into museums, including one full of weapons used by a 19th century revolutionary warlord, one Yang DaLu according to the information panel, who apparently wasn’t famous enough to make it onto the English language Wikipedia.

There didn’t seem to be any restaurants, or at least none that were open in the winter, but luckily I made friends with this slightly batty old lady who made me some kind of hotpot lunch for 50元. Unfortunately she also forced me to drink a whole cup of her homemade 米酒, which is a sort of lethal rice wine, from a large tank in her living room – despite my protests of “我快醉了!”. I refused to buy a bottle. Anyway I managed to escape and decided to walk off my slight tipsiness by exploring down the river valley towards the lower village.

This is halfway down the landscaped path between the two villages. The lower village is on the main road and a bit more modern but the bridge over the river is very elegant.

Xijiang Miao Village

March 22nd, 2017

So one of the tourist highlights of Guizhou is visiting the collection of traditional ethnic minority villages in the province. There’s rather a lot so I picked one area 黔东南 “Qiandongnan” as a base and spent a few days travelling around and exploring by bus. 西江寨 “XiJiang village” is today’s stop, and probably one of the more famous of these villages, inhabited by the 苗 “Miao” nationality. 寨 “zhài” can be our word of the day and it means “stockaded village”, you see it in all the place names in this area.

The main street of the village along this river feels a bit touristy and a little too shiny. But it’s all very picturesque. If you head higher up the mountain it starts to become a bit more authentic, and people don’t seem to mind you wandering around peering at their houses. I tried chatting to some of them but their accent was pretty impenetrable, and my Mandarin isn’t great to start with.

In the afternoon I went for a walk in the countryside nearby. All around are these rice terraces. Lonely Planet suggested you could get to another village by walking up over the top of the mountain and into the next valley but the guidebook directions were almost uselessly vague and the upper levels of the terraces were difficult to navigate so I gave up. I did notice however that all the rice paddies seemed a bit… dead. I thought gloomily that maybe all the villages had given up traditional farming to live off the tourism money, but a Chinese friend said it was probably because it’s winter and not the rice growing season so they were off doing other work. This seemed to be supported by the massive amount of construction work going on, I guess they have to spend that hefty village entry fee on something.


March 16th, 2017

Done with work now it’s time to go adventuring! Actually this happened a few weeks ago, I’ve just been very lacklustre updating this blog. I’ve done a lot of exploring around the Suzhou area so I thought I’d like to try somewhere a bit different so this time I took a flight to Guizhou province in the south.

Guiyang 贵阳 is the capital of Guizhou. The 贵 “gui” bit means “expensive” which is presumably a joke because everything here is really cheap. It’s the first place I’ve been in China where prices regularly have the decimal point in them.

The city doesn’t have a whole lot of tourist attractions but the main one is this called Jiaxu Pavillion in the centre of town. It’s free to get in to which is nice, and there’s a temple on the opposite bank which is pleasant to wander around.

The area around the river is quite modern, the Chinese government investing a lot of money in developing the south west at the moment. But the rest of the city feels a bit more “traditional”.

On the second day I wasn’t really sure what to do. I thought about going to an ancient village that the guidebook mentioned but lack of time and poor planning on my part meant I had to give up on that. So instead I went to a “mountain park” 黔灵公园 more or less at random, which was actually a really good choice!

The park is just on the edge of the city and very busy on a Sunday morning. There’s a whole bunch of attractions including a temple and a zoo with some rather sad looking bears and tigers. But the best thing is the hordes of wild monkeys who are everywhere and not at all afraid of humans.

In fact they seem to be a kind of pest as there was a guy with a sling – presumably in an official capacity – flinging stones at them to keep them off the paths.